//
//  MPTMeTableViewCell.m
//  MPTLive
//
//  Created by caixun on 15/8/24.
//  Copyright (c) 2015年 Jeakin. All rights reserved.
//

#import "MPTMeTableViewCell.h"
#import "MPTMeCellItemView.h"


#pragma mark - ******************************** 公共宏 **********************************
// 显示图片的高/宽
#define ImageScale (480/480.0)
// 该宏的含义与MPTMeCellItemView中OtherH的含义一样，如果不清楚可以看MPTMeCellItemView中的OtherH的注释
#define OtherH (46)
// 个人中心每一个cell中的内容距离cell顶部的距离
#define Cell_Top_Space (10)
// MPTMeCellItemView距离屏幕左侧间距
#define Left_Space (10)
// MPTMeCellItemView距离屏幕右侧间距
#define Right_Space (10)
// 两个MPTMeCellItemView之间的间距
#define Space (10)



@interface MPTMeTableViewCell ()

@property (nonatomic, strong) MPTMeCellItemView *cellLeftItemView;
@property (nonatomic, strong) MPTMeCellItemView *cellRightItemView;

@end


@implementation MPTMeTableViewCell

- (void)awakeFromNib
{
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (void)initCellLeftContent
{
    CGRect rect = CGRectMake(Left_Space,
                             Cell_Top_Space,
                             ((screenW-Left_Space-Space-Right_Space)/2),
                             ((screenW-Left_Space-Space-Right_Space)/2)*ImageScale+OtherH);
    self.cellLeftItemView = [[MPTMeCellItemView alloc] initWithFrame:rect];
    [self.cellLeftItemView initViewContent];
    [self.contentView addSubview:self.cellLeftItemView];
    
    self.cellLeftItemView.layer.cornerRadius = 3;
    self.cellLeftItemView.clipsToBounds = YES;
}

- (void)initCellRightContent
{
    CGRect rect = CGRectMake(Left_Space+Space+((screenW-Left_Space-Space-Right_Space)/2),
                             Cell_Top_Space,
                             ((screenW-Left_Space-Space-Right_Space)/2),
                             ((screenW-Left_Space-Space-Right_Space)/2)*ImageScale+OtherH);
    self.cellRightItemView = [[MPTMeCellItemView alloc] initWithFrame:rect];
    [self.cellRightItemView initViewContent];
    [self.contentView addSubview:self.cellRightItemView];
    
    self.cellRightItemView.layer.cornerRadius = 3;
    self.cellRightItemView.clipsToBounds = YES;
}

- (void)setCellLeftContent:(MeVideoModel *)videoModel WithTarget:(id)target withAction:(SEL)playAction
{
    [self.cellLeftItemView setViewContent:videoModel WithTarget:target withAction:playAction];
}

- (void)setCellRightContent:(MeVideoModel *)videoModel WithTarget:(id)target withAction:(SEL)playAction
{
    [self.cellRightItemView setViewContent:videoModel WithTarget:target withAction:playAction];
}

+ (float)getCellH
{
    return ((screenW-Left_Space-Space-Right_Space)/2)*ImageScale+Cell_Top_Space+OtherH;
}

@end
